package com.example.administrator.yanfoxconn.adapter;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.yanfoxconn.R;
import com.example.administrator.yanfoxconn.activity.GoodsIntelligenceActivity;
import com.example.administrator.yanfoxconn.activity.KKCHeckList2Activity;
import com.example.administrator.yanfoxconn.activity.KKCHeckListActivity;
import com.example.administrator.yanfoxconn.bean.GoodsMessage;
import com.example.administrator.yanfoxconn.bean.KKGWMessage;

import java.util.List;


/**
 * 關務設備 點檢詳情 的 適配器
 * Created by wangqian on 2019/6/28.
 */

public class KKCheckList2Adapter extends BaseAdapter {

    private KKCHeckList2Activity activity;
    private List<KKGWMessage> lists;


    public KKCheckList2Adapter(KKCHeckList2Activity activity, List<KKGWMessage> lists) {

        this.activity = activity;
        this.lists = lists;
    }

    @Override
    public int getCount() {
        Log.e("--------","lists.size()==="+lists.size());
        return lists.size();
    }

    @Override
    public Object getItem(int i) {
        return lists.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        int num = position +1;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_kk_check_list2, null);

//            holder.tvNo = convertView.findViewById(R.id.tv_list_no);
//            holder.tvName = convertView.findViewById(R.id.tv_list_name);
//            holder.tvMac = convertView.findViewById(R.id.tv_list_mac);
//            holder.tvSn = convertView.findViewById(R.id.tv_list_sn);
//            holder.tvXian = convertView.findViewById(R.id.tv_list_xian);
//            holder.tvPin = convertView.findViewById(R.id.tv_list_pin);
//            holder.tvCol = convertView.findViewById(R.id.tv_list_col);
//            holder.tvNum = convertView.findViewById(R.id.tv_list_num);

            holder.tvNum = convertView.findViewById(R.id.tv_num);
            holder.tvStorage = convertView.findViewById(R.id.tv_s_storage);
            holder.tvRecordName = convertView.findViewById(R.id.tv_record_name);
            holder.tvControlNo = convertView.findViewById(R.id.tv_control_no);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tvNum.setText((position+1)+"");
        holder.tvStorage.setText(lists.get(position).getS_STORAGE());
        holder.tvRecordName.setText(lists.get(position).getRECORDNAME());
        holder.tvControlNo.setText(lists.get(position).getCONTROLNO());


        return convertView;
    }

    private class ViewHolder {
        //        public TextView tvNo, tvName, tvMac, tvSn,tvXian, tvPin, tvCol, tvNum;//編號,名稱,MAC,SN,顯卡,品牌,顏色,數量单位
        public TextView tvNum, tvStorage, tvRecordName, tvControlNo;//序號，位置，名稱，管制編號
    }


}